//
//  CellForHead.m
//  MY Project For Sport
//
//  Created by dllo on 16/2/29.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForHead.h"

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface CellForHead ()
@property (nonatomic, retain)UIVisualEffectView *visual;

@property (nonatomic, retain)UIButton *manage;
@end

@implementation CellForHead

-(void)dealloc {
    [_image release];
    [_heard release];
    [_visual release];
    [_singIn release];
    [_manage release];
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.image = [[UIImageView alloc] init];
        [self.contentView addSubview:self.image];
        [_image release];
        
        
        self.visual = [[UIVisualEffectView alloc] init];
        [self.image addSubview:self.visual];
        [_visual release];
        
        
        self.heard = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:self.heard];
        
        self.singIn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:self.singIn];
      
        
        self.manage = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:self.manage];
      
    }
    return self;

}

- (void)layoutSubviews {

    [super layoutSubviews];
    
    self.image.frame = CGRectMake(5 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width - 10 * WEIGHTT, self.contentView.frame.size.height - 10 * HEIGHTT);
    self.image.backgroundColor = [UIColor blueColor];
    self.image.image = [UIImage imageNamed:@"background.jpg"];
    
    
    self.visual.frame = CGRectMake(0, 0, self.image.frame.size.width, self.image.frame.size.height);
    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:1];
    self.visual.effect = effect;
    
    
    self.heard.frame = CGRectMake(0, 0, self.contentView.frame.size.width / 4 , self.contentView.frame.size.width / 4);
    self.heard.center = self.contentView.center;
    
    self.heard.layer.cornerRadius = self.contentView.frame.size.width / 8;
    self.heard.layer.masksToBounds = YES;
    self.heard.backgroundColor = [UIColor redColor];
   // [self.heard addTarget:self action:@selector(addHeardAction:) forControlEvents:UIControlEventTouchUpInside];
   [self.heard setBackgroundImage:[UIImage imageNamed:@"head1.jpg"] forState:UIControlStateNormal];
    
    self.singIn.frame = CGRectMake(self.contentView.frame.size.width / 5, self.contentView.frame.size.height/ 6 * 4 + 10 * HEIGHTT, self.contentView.frame.size.width /5 , 35 * HEIGHTT);
    self.singIn.backgroundColor = [UIColor redColor];
    [self.singIn setTitle:@"登录" forState:UIControlStateNormal];
    
    
    
    self.manage.frame = CGRectMake(self.contentView.frame.size.width - self.contentView.frame.size.width / 5 * 2, self.contentView.frame.size.height/ 6 * 4 + 10 * HEIGHTT, self.contentView.frame.size.width /5 , 35 * HEIGHTT);
    self.manage.backgroundColor = [UIColor redColor];
    [self.manage setTitle:@"注册" forState:UIControlStateNormal];
    
    
}

//- (void)addHeardAction:(UIButton *) button {
//
//
//        UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init];
//        imagePicker.allowsEditing = YES;
//        imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
//        imagePicker.delegate = self;
//    
//        [self presentViewController:imagePicker animated:YES completion:^{
//            NSLog(@"打开相册");
//        }];
//        
//        
//   
//
//}
//
//- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
//{
//    [picker dismissViewControllerAnimated:YES completion:^{
//        NSLog(@"取消");
//    }];
//}
//
//- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
//{
//    self.image.image = info[UIImagePickerControllerEditedImage];
//    NSLog(@"%@",info);
//    [picker dismissViewControllerAnimated:YES completion:^{
//        NSLog(@"选照片");
//    }];
//    
//    
//    
//}
//


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
